//
//  VectorHelper.m
//  iFly
//
//  Created by User-10 on 12/7/14.
//  Copyright (c) 2014 TeamDifferent. All rights reserved.
//

#import "VectorHelper.h"

@implementation VectorHelper

+(CGPoint) vectorAddPoint:(CGPoint) a toPoint:(CGPoint) b {
    return CGPointMake(a.x + b.x, a.y + b.y);
}

+(CGPoint) vectorSubPoint:(CGPoint) a toPoint:(CGPoint) b {
    return CGPointMake(a.x - b.x, a.y - b.y);
}

+(CGPoint) vectorMultPoint:(CGPoint) a withMultiplier:(float) b {
    return CGPointMake(a.x * b, a.y * b);
}

+(float) vectorLength:(CGPoint) a {
    return sqrtf(a.x * a.x + a.y * a.y);
}

// Makes a vector have a length of 1
+(CGPoint) vectorNormalize:(CGPoint) a {
    float length = [self vectorLength:a];
    return CGPointMake(a.x / length, a.y / length);
}

@end
